

package com.hazelcast.internal.management.operation;

import com.hazelcast.internal.dynamicconfig.ConfigurationService;
import com.hazelcast.internal.management.ManagementDataSerializerHook;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;

import java.io.IOException;
import java.util.UUID;

public class UpdateConfigOperation extends AbstractDynamicConfigOperation {

    private String configPatch;

    public UpdateConfigOperation() {
    }

    public UpdateConfigOperation(String configPatch) {
        this.configPatch = configPatch;
    }

    @Override
    public int getClassId() {
        return ManagementDataSerializerHook.UPDATE_CONFIG_OPERATION;
    }

    @Override
    protected UUID startUpdateProcess() {
        ConfigurationService configService = getService();
        return configService.updateAsync(configPatch);
    }

    @Override
    protected void writeInternal(ObjectDataOutput out) throws IOException {
        out.writeString(configPatch);
    }

    @Override
    protected void readInternal(ObjectDataInput in) throws IOException {
        configPatch = in.readString();
    }
}
